package com.example.androidmainshixun.view;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.androidmainshixun.R;
import com.example.androidmainshixun.adapter.CartBean;
import com.example.androidmainshixun.entity.Goods;

public class Goods2Activity extends AppCompatActivity {
    private ImageView mImage;
    private Button mButton;
    private CartBean cartBean;
    private Goods mGoods; // 当前商品的实例

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_goods2);
        mImage=findViewById(R.id.image1);
        mButton=findViewById(R.id.button);
        // 从Intent中获取传递过来的数据
        int position = getIntent().getIntExtra("POSITION", -1); // 获取位置

        mImage.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        
        mButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onAddToCartClick(); // 确保正确调用 onAddToCartClick 方法
            }
        });
    }

    private void onAddToCartClick() {
        if (mGoods != null) {
            addToCart();
        } else {
            Toast.makeText(this, "商品数据为空", Toast.LENGTH_SHORT).show();
        }
    }

    private void addToCart() {
    }
}
